package lancoo.com.net.retrofitrxjava.interceptor;

import android.util.Log;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by pengmi on 2018/11/14.
 * Description:
 */

public class RequestHeaderInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request originalRequest = chain.request();
        Log.e("url",originalRequest.url().toString());
        String url = originalRequest.url().toString();
        if (url.contains("Decrypt")){
            Request updateRequest = originalRequest.newBuilder()
                    .header("Content-Type", "application/json; charset=utf-8")
//                    .header("Accept", "*/*")
//                    .header("Accept-Encoding", "gzip")
                    .build();
            return chain.proceed(updateRequest);
        }else {
            return chain.proceed(originalRequest);
        }

    }

}

